{include file="pageheader_erp.htm"}

{insert_scripts files="../js/jquery.1.3.2.js"}

<!-- start bank account list -->
 <div class="list-div" id="listDiv">
<table  cellpadding="3" cellspacing="1">
  <tr>
    <th  width="5%">{$lang.erp_bank_account_id}</th>
	<th>{$lang.erp_bank_account_name}</th>
	<th>{$lang.erp_bank_account_no}</th>
	<!-- <th width="10%">{$lang.erp_bank_account_balance}</th> -->
	<th width="10%">{$lang.erp_is_valid}</th>
	<th width="10%">{$lang.erp_operation}</th>
  </tr>
  {foreach from=$bank_account_info key=key item=bank_account_info}
	<tr>
		<td align="center">{$bank_account_info.account_id}</td>
		<td>{$bank_account_info.account_name}</td>
		<td >{$bank_account_info.account_no}</td>
		<!-- <td align="center">{$bank_account_info.account_balance}</td> -->
		<td align="center"><span id="is_valid_{$bank_account_info.account_id}" style="cursor:pointer;color:{if $bank_account_info.is_valid eq 1}red;{else}black;{/if}">{if $bank_account_info.is_valid}{$lang.erp_yes}{else}{$lang.erp_no}{/if}</span></td>
		<td align="center">
			<a href="javascript:delete_it({$bank_account_info.account_id})">{$lang.erp_operation_delete}</a>
		</td>
	</tr>
  {foreachelse}
  <tr><td class="no-records" colspan="7">{$lang.no_records}</td></tr>
  {/foreach}
</table>
</div>
<!-- end bank account list -->

{literal}
<script language="JavaScript">
	
	function delete_it(account_id)
	{
		function deleteBankAccountResponse(res)
		{
			if(res.error==3)
			{
				alert(res.message);
				window.document.location='erp_finance_manage.php?act=bank_account_setting';
			}
			else if(res.error==0){
				window.document.location='erp_finance_manage.php?act=bank_account_setting';
			}
			else{
				alert(res.message);
			}
		}
	
		if(confirm('{$lang.erp_sure_to_delete}')){
			Ajax.call('erp_bank_account.php?act=delete_bank_account', 'account_id=' + account_id, deleteBankAccountResponse, 'POST', 'JSON');
		}		
	}

   $(document).ready(function(){
   		
		//设置是否有效
   		$("span[id^='is_valid_']").click(function(){
			var $select_item=$(this);
			var account_id=$select_item.attr('id');
			account_id=account_id.substr('is_valid_'.length,account_id.length-'is_valid_'.length);
			
			function changeIsValidResponse(res)
			{
				if(res.error==0 && res.is_valid==1)
				{
					$select_item.css('color','red');
					$select_item.text('{$lang.erp_yes}');
					//alert(res.message);
				}
				else if(res.error==0 && res.is_valid===0)
				{
					$select_item.css('color','black');
					$select_item.text('{$lang.erp_no}');
					//alert(res.message);
				}
				else{
					
					alert(res.message);
				}
			}
			
			Ajax.call('erp_bank_account.php?act=change_is_valid', 'account_id=' + account_id, changeIsValidResponse, 'POST', 'JSON');
		});
		
		
   });   
</script>
{/literal}
{include file="pagefooter.htm"}

